; global.inc
; Global definitions

M_NTSC		= $05
M_PAL		= $0C

NTSC_TIMER_VALUE =	261 * 65 - 2
PAL_TIMER_VALUE = 	312 * 71 - 2		; Original: $4826

PAL_TPS		= 50
NTSC_TPS	= 60

NTSC_LINE = $75		; raster line 234/235
PAL_LINE = $90		; raster line 288/289

VIC_BASE = $9000

VIA1_BASE = $9110
VIA2_BASE = $9120

WARMSTART_VECTOR = $0302
IRQ_VECTOR = $0314
BRK_VECTOR = $0316

COLS = 22
ROWS = 23

	VIDEO_BASE0 = $1000
	VIDEO_BASE1 = $1200
	CHAR_BASE0  = $1400
	CHAR_BASE1  = $1800
	COLOR_BASE0 = $9400
	COLOR_BASE1 = $9600

	VIDEO_BASE = VIDEO_BASE0
	COLOR_BASE = COLOR_BASE0


.IFDEF _IN_GLOBAL

	.exportzp tmpptr1
	.exportzp tmpptr2
	.exportzp tmpptr3
	.exportzp tmpptr4
	
.ELSE

	.importzp tmpptr1
	.importzp tmpptr2
	.importzp tmpptr3
	.importzp tmpptr4

.ENDIF

.macro inc16 adr16
	.local @l1
		inc (adr16)
		bne @l1
		inc (adr16)+1
	@l1:
.endmacro

.macro mov16 adr16, ofs8
	.local @l1
		clc
		lda adr16
		adc #ofs8
		sta adr16
		bcc @l1
		inc adr16+1
	@l1:
.endmacro

.macro ld16 adr16, val16
		lda #<(val16)		
		sta adr16
		lda #>(val16)
		sta adr16+1
.endmacro

.macro cp16 src16, tgt16
		lda src16		
		sta tgt16
		lda src16+1
		sta tgt16+1
.endmacro
		
.macro mva src16, tgt16, ofs8
		clc
		lda src16
		adc #ofs8
		sta tgt16
		lda src16+1
		adc #0
		sta tgt16+1
.endmacro

.macro shl16 adr16, cnt
	.repeat cnt
		asl adr16
		rol adr16+1
	.endrep
.endmacro
